1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module pango.PgGlyphItem; 26 27 private import glib.ListSG; 28 private import glib.MemorySlice; 29 private import glib.Str; 30 private import gobject.ObjectG; 31 private import linker.Loader; 32 private import pango.PgAttributeList; 33 private import pango.PgGlyphString; 34 private import pango.PgItem; 35 private import pango.c.functions; 36 public import pango.c.types; 37 38 39 /** 40 * A `PangoGlyphItem` is a pair of a `PangoItem` and the glyphs 41 * resulting from shaping the items text. 42 * 43 * As an example of the usage of `PangoGlyphItem`, the results 44 * of shaping text with `PangoLayout` is a list of `PangoLayoutLine`, 45 * each of which contains a list of `PangoGlyphItem`. 46 */ 47 public final class PgGlyphItem 48 { 49 /** the main Gtk struct */ 50 protected PangoGlyphItem* pangoGlyphItem; 51 protected bool ownedRef; 52 53 /** Get the main Gtk struct */ 54 public PangoGlyphItem* getPgGlyphItemStruct(bool transferOwnership = false) 55 { 56 if (transferOwnership) 57 ownedRef = false; 58 return pangoGlyphItem; 59 } 60 61 /** the main Gtk struct as a void* */ 62 protected void* getStruct() 63 { 64 return cast(void*)pangoGlyphItem; 65 } 66 67 /** 68 * Sets our main struct and passes it to the parent class. 69 */ 70 public this (PangoGlyphItem* pangoGlyphItem, bool ownedRef = false) 71 { 72 this.pangoGlyphItem = pangoGlyphItem; 73 this.ownedRef = ownedRef; 74 } 75 76 ~this () 77 { 78 if ( Linker.isLoaded(LIBRARY_PANGO[0]) && ownedRef ) 79 pango_glyph_item_free(pangoGlyphItem); 80 } 81 82 83 /** 84 * corresponding `PangoItem` 85 */ 86 public @property PgItem item() 87 { 88 return ObjectG.getDObject!(PgItem)(pangoGlyphItem.item, false); 89 } 90 91 /** Ditto */ 92 public @property void item(PgItem value) 93 { 94 pangoGlyphItem.item = value.getPgItemStruct(); 95 } 96 97 /** 98 * corresponding `PangoGlyphString` 99 */ 100 public @property PgGlyphString glyphs() 101 { 102 return ObjectG.getDObject!(PgGlyphString)(pangoGlyphItem.glyphs, false); 103 } 104 105 /** Ditto */ 106 public @property void glyphs(PgGlyphString value) 107 { 108 pangoGlyphItem.glyphs = value.getPgGlyphStringStruct(); 109 } 110 111 /** 112 * shift of the baseline, relative to the baseline 113 * of the containing line. Positive values shift upwards 114 */ 115 public @property int yOffset() 116 { 117 return pangoGlyphItem.yOffset; 118 } 119 120 /** Ditto */ 121 public @property void yOffset(int value) 122 { 123 pangoGlyphItem.yOffset = value; 124 } 125 126 /** 127 * horizontal displacement to apply before the 128 * glyph item. Positive values shift right 129 */ 130 public @property int startXOffset() 131 { 132 return pangoGlyphItem.startXOffset; 133 } 134 135 /** Ditto */ 136 public @property void startXOffset(int value) 137 { 138 pangoGlyphItem.startXOffset = value; 139 } 140 141 /** 142 * horizontal displacement to apply after th 143 * glyph item. Positive values shift right 144 */ 145 public @property int endXOffset() 146 { 147 return pangoGlyphItem.endXOffset; 148 } 149 150 /** Ditto */ 151 public @property void endXOffset(int value) 152 { 153 pangoGlyphItem.endXOffset = value; 154 } 155 156 /** */ 157 public static GType getType() 158 { 159 return pango_glyph_item_get_type(); 160 } 161 162 /** 163 * Splits a shaped item (`PangoGlyphItem`) into multiple items based 164 * on an attribute list. 165 * 166 * The idea is that if you have attributes that don't affect shaping, 167 * such as color or underline, to avoid affecting shaping, you filter 168 * them out ([method@Pango.AttrList.filter]), apply the shaping process 169 * and then reapply them to the result using this function. 170 * 171 * All attributes that start or end inside a cluster are applied 172 * to that cluster; for instance, if half of a cluster is underlined 173 * and the other-half strikethrough, then the cluster will end 174 * up with both underline and strikethrough attributes. In these 175 * cases, it may happen that @item->extra_attrs for some of the 176 * result items can have multiple attributes of the same type. 177 * 178 * This function takes ownership of @glyph_item; it will be reused 179 * as one of the elements in the list. 180 * 181 * Params: 182 * text = text that @list applies to 183 * list = a `PangoAttrList` 184 * 185 * Returns: a 186 * list of glyph items resulting from splitting @glyph_item. Free 187 * the elements using [method@Pango.GlyphItem.free], the list using 188 * g_slist_free(). 189 * 190 * Since: 1.2 191 */ 192 public ListSG applyAttrs(string text, PgAttributeList list) 193 { 194 auto __p = pango_glyph_item_apply_attrs(pangoGlyphItem, Str.toStringz(text), (list is null) ? null : list.getPgAttributeListStruct()); 195 196 if(__p is null) 197 { 198 return null; 199 } 200 201 return new ListSG(cast(GSList*) __p, true); 202 } 203 204 /** 205 * Make a deep copy of an existing `PangoGlyphItem` structure. 206 * 207 * Returns: the newly allocated `PangoGlyphItem` 208 * 209 * Since: 1.20 210 */ 211 public PgGlyphItem copy() 212 { 213 auto __p = pango_glyph_item_copy(pangoGlyphItem); 214 215 if(__p is null) 216 { 217 return null; 218 } 219 220 return ObjectG.getDObject!(PgGlyphItem)(cast(PangoGlyphItem*) __p, true); 221 } 222 223 /** 224 * Frees a `PangoGlyphItem` and resources to which it points. 225 * 226 * Since: 1.6 227 */ 228 public void free() 229 { 230 pango_glyph_item_free(pangoGlyphItem); 231 ownedRef = false; 232 } 233 234 /** 235 * Given a `PangoGlyphItem` and the corresponding text, determine the 236 * width corresponding to each character. 237 * 238 * When multiple characters compose a single cluster, the width of the 239 * entire cluster is divided equally among the characters. 240 * 241 * See also [method@Pango.GlyphString.get_logical_widths]. 242 * 243 * Params: 244 * text = text that @glyph_item corresponds to 245 * (glyph_item->item->offset is an offset from the 246 * start of @text) 247 * logicalWidths = an array whose length is the number of 248 * characters in glyph_item (equal to glyph_item->item->num_chars) 249 * to be filled in with the resulting character widths. 250 * 251 * Since: 1.26 252 */ 253 public void getLogicalWidths(string text, int[] logicalWidths) 254 { 255 pango_glyph_item_get_logical_widths(pangoGlyphItem, Str.toStringz(text), logicalWidths.ptr); 256 } 257 258 /** 259 * Adds spacing between the graphemes of @glyph_item to 260 * give the effect of typographic letter spacing. 261 * 262 * Params: 263 * text = text that @glyph_item corresponds to 264 * (glyph_item->item->offset is an offset from the 265 * start of @text) 266 * logAttrs = logical attributes for the item 267 * (the first logical attribute refers to the position 268 * before the first character in the item) 269 * letterSpacing = amount of letter spacing to add 270 * in Pango units. May be negative, though too large 271 * negative values will give ugly results. 272 * 273 * Since: 1.6 274 */ 275 public void letterSpace(string text, PangoLogAttr[] logAttrs, int letterSpacing) 276 { 277 pango_glyph_item_letter_space(pangoGlyphItem, Str.toStringz(text), logAttrs.ptr, letterSpacing); 278 } 279 280 /** 281 * Modifies @orig to cover only the text after @split_index, and 282 * returns a new item that covers the text before @split_index that 283 * used to be in @orig. 284 * 285 * You can think of @split_index as the length of the returned item. 286 * @split_index may not be 0, and it may not be greater than or equal 287 * to the length of @orig (that is, there must be at least one byte 288 * assigned to each item, you can't create a zero-length item). 289 * 290 * This function is similar in function to pango_item_split() (and uses 291 * it internally.) 292 * 293 * Params: 294 * text = text to which positions in @orig apply 295 * splitIndex = byte index of position to split item, relative to the 296 * start of the item 297 * 298 * Returns: the newly allocated item representing text before 299 * @split_index, which should be freed 300 * with pango_glyph_item_free(). 301 * 302 * Since: 1.2 303 */ 304 public PgGlyphItem split(string text, int splitIndex) 305 { 306 auto __p = pango_glyph_item_split(pangoGlyphItem, Str.toStringz(text), splitIndex); 307 308 if(__p is null) 309 { 310 return null; 311 } 312 313 return ObjectG.getDObject!(PgGlyphItem)(cast(PangoGlyphItem*) __p, true); 314 } 315 }